let sum = function(arr) {
    return sumByRecursion(arr, 0)
}

// 计算arr[l..<n]所有数的和
let sumByRecursion = function(arr, l) {
    if (l === arr.length) {
        return 0
    }else {
        return arr[l] + sumByRecursion(arr, l+1)
    }
}

let l = [1, 2, 3, 4, 5]
console.log(`${l}.sum = ${sum(l)}`)